const WinReg = require("winreg");
const noop = () => {};

function getKey(hive, key) {
    return new WinReg({
        hive,
        key
    });
}

function getAutoRun() {
    return getKey(WinReg.HKCU, "\\Software\\Microsoft\\Windows\\CurrentVersion\\Run");
}

module.exports = {
    setAutoRun: (name, file, callback) => {
        getAutoRun().set(name, WinReg.REG_SZ, file, callback || noop);
    },
    removeAutoRun: (name, callback) => {
        getAutoRun().remove(name, callback || noop);
    }
}